import 'package:flutter/material.dart';
import 'package:tiktokadult/assets_tool/images.dart';
import 'package:tiktokadult/hj_page/cartoon_business/widget/acg_source_manager.dart';
import 'package:tiktokadult/hj_utils/screen.dart';
import 'package:tiktokadult/hj_utils/widget_utils.dart';
import 'package:tiktokadult/tools_base/widget/net_image_widget.dart';

import '../../hj_model/cartoon_media_info.dart';

//小说头部
class NovelHeader extends StatefulWidget {
  final ACGSourceManager? manager;
  const NovelHeader({super.key, this.manager});

  @override
  State<NovelHeader> createState() => _NovelHeaderState();
}

class _NovelHeaderState extends State<NovelHeader> {
  CartoonMediaInfo? get info => widget.manager?.mediaInfo;

  @override
  Widget build(BuildContext context) {
    return _buildHeader();
  }

  _buildHeader() {
    return Stack(
      children: [
        Positioned(
          left: 0,
          top: 0,
          right: 0,
          child: NetworkImageLoader(
            imageUrl: info?.coverH ?? '',
          ),
        ),
        Positioned.fill(
            child: Container(
          color: Colors.black.withOpacity(.7),
        )),
        Padding(
          padding: EdgeInsets.symmetric(horizontal: 16),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.start,
            children: [
              (screen.paddingTop + 72).sizeBoxH,
              Row(
                children: [
                  Stack(
                    children: [
                      NetworkImageLoader(
                        imageUrl: info?.coverH ?? '',
                        width: 111,
                        height: 130,
                      ),
                      if (info?.isAudiobooks == true)
                        Positioned(
                          top: 6,
                          left: 6,
                          child: Image.asset('noval_sign.png'.acgImgPath, width: 20),
                        )
                    ],
                  ),
                  12.sizeBoxW,
                  Expanded(
                      child: Column(
                    crossAxisAlignment: CrossAxisAlignment.start,
                    children: [
                      Text(
                        info?.title ?? '',
                        style: textStyle(14, Colors.white, FontWeight.w500),
                        maxLines: 2,
                        overflow: TextOverflow.ellipsis,
                      ),
                      6.sizeBoxH,
                      Text(
                        '${info?.countView.humanizeFormat}人阅读',
                        style: textStyle(12, Color(0xff999999), FontWeight.w400),
                      ),
                    ],
                  )),
                ],
              ),
              12.sizeBoxH,
            ],
          ),
        ),
      ],
    );
  }
}
